package com.ruoyi.graduation.service.impl;

import java.util.Collections;
import java.util.List;

import com.ruoyi.firefighter.domain.FirefighterInfo;
import com.ruoyi.firefighter.service.IFirefighterInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.graduation.mapper.GraduationSchoolMapper;
import com.ruoyi.graduation.domain.GraduationSchool;
import com.ruoyi.graduation.service.IGraduationSchoolService;

/**
 * 毕业院校信息Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-28
 */
@Service
public class GraduationSchoolServiceImpl implements IGraduationSchoolService
{
    @Autowired
    private GraduationSchoolMapper graduationSchoolMapper;
    @Autowired
    private IFirefighterInfoService firefighterInfoService;
    /**
     * 查询毕业院校信息
     *
     * @param id 毕业院校信息主键
     * @return 毕业院校信息
     */
    @Override
    public GraduationSchool selectGraduationSchoolById(Long id)
    {
        return graduationSchoolMapper.selectGraduationSchoolById(id);
    }

    /**
     * 查询毕业院校信息列表
     *
     * @param graduationSchool 毕业院校信息
     * @return 毕业院校信息
     */
    @Override
    public List<GraduationSchool> selectGraduationSchoolList(GraduationSchool graduationSchool)
    {
        return graduationSchoolMapper.selectGraduationSchoolList(graduationSchool);
    }

    /**
     * 新增毕业院校信息
     *
     * @param graduationSchool 毕业院校信息
     * @return 结果
     */
    @Override
    public int insertGraduationSchool(GraduationSchool graduationSchool)
    {
        String firefighterIdCard = graduationSchool.getFirefighterIdCard();
        FirefighterInfo firefighterInfo = new FirefighterInfo();
        firefighterInfo.setIdCardNumber(firefighterIdCard);
        FirefighterInfo firefighterInfo1 = firefighterInfoService.selectFirefighterInfoBySfz(firefighterInfo);
        graduationSchool.setFirefighterId(firefighterInfo1.getUserId().toString());
        return graduationSchoolMapper.insertGraduationSchool(graduationSchool);
    }

    /**
     * 修改毕业院校信息
     *
     * @param graduationSchool 毕业院校信息
     * @return 结果
     */
    @Override
    public int updateGraduationSchool(GraduationSchool graduationSchool)
    {
        return graduationSchoolMapper.updateGraduationSchool(graduationSchool);
    }

    /**
     * 批量删除毕业院校信息
     *
     * @param ids 需要删除的毕业院校信息主键
     * @return 结果
     */
    @Override
    public int deleteGraduationSchoolByIds(Long[] ids)
    {
        return graduationSchoolMapper.deleteGraduationSchoolByIds(ids);
    }

    /**
     * 删除毕业院校信息信息
     *
     * @param id 毕业院校信息主键
     * @return 结果
     */
    @Override
    public int deleteGraduationSchoolById(Long id)
    {
        return graduationSchoolMapper.deleteGraduationSchoolById(id);
    }

    @Override
    public List<GraduationSchool> selectGraduationSchoolByfId(String string) {
        return graduationSchoolMapper.selectGraduationSchoolByfId(string);
    }

    @Override
    public void deleteGraduationSchoolById1(Long userId) {
        graduationSchoolMapper.selectGraduationSchoolByfIduser(userId);
    }
}
